package display;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;
import java.util.HashMap;

import service.PaisManager;
import domain.Pais;

public class PaisAgregar implements Controller {
 protected final Log logger = LogFactory.getLog(getClass());
 private PaisManager PaisManager;
 public ModelAndView handleRequest(HttpServletRequest request,
   HttpServletResponse response)
   throws ServletException, IOException {
   String id = request.getParameter("id");
   String nombre = request.getParameter("nombre");
   String tipo = request.getParameter("tipo");
   Pais profe = new Pais();
   profe.setId(id);
   profe.setNombre(nombre);
   profe.setTipo(tipo);
   PaisManager.addPais(profe);
   String now = (new java.util.Date()).toString();
   logger.info("returning pais view with " + now);
   Map<String, Object> myModel = new HashMap<String, Object>();
   myModel.put("now", now);
   myModel.put("paises", this.PaisManager.getPaises());
   return new ModelAndView("paisView", "model", myModel);
 }
 public void setPaisManager(PaisManager PaisManager) {
   this.PaisManager = PaisManager;
} }